Popping data with timeouts is more involved than pushing; note that the reader thread is waiting on the condition variable. 具有超时限制的取出数据操作比添加数据复杂;注意,读线程会等待条件变量。
The function primarily used for this is pthread_cond_wait(). It takes two arguments; the first is a pointer to a condition variable, and the second is a locked mutex. 函数pthreadcondwait()主要就是用于阻塞线程的,它有两个参数;第一个是一个指向条件变量的指针,第二个是一个锁定了的互斥量。
Therefore, at the end of it all, you now have two reader threads, both waiting on the condition variable, and the mutex is unlocked. 因此,最后两个读线程都等待条件变量,互斥锁没有被锁住。
Next, the reader thread needs to ensure ( and this is the second check you perform) that it does not wait on the condition variable any more than the specified timeout period. 接下来,读线程需要确保(这是第二个检查)它等待条件变量的时间不超过指定的超时时间。
When you're done with a condition variable, you can release any resources allocated during initialization with a call to pthread_cond_destroy(). 当不再使用条件变量时,应该调用pthreadconddestroy()释放它在初始化时分配的资源。
However, pthread_cond_signal unblocks at least one of the threads waiting on the condition variable, not necessarily the reader thread with the longest waiting time. 但是,pthreadcondsignal会释放至少一个等待条件变量的线程,这个线程不一定是等待时间最长的读线程。
To work around this omission, I use the POSIX condition variable emulations synchronization primitives, which are outlined in the series of articles. 为解决此缺憾,我使用POSIX条件变量模拟同步原语,并在一系列文章中对此进行了概述。
In some implementations, threads may occasionally wake up without a signal sent to their condition variable. 在有些实现中,线程可能偶尔在没有信号送到条件变量的情况下醒过来。
If the queue is full, the writer thread waits on the_wcond condition variable; the reader thread will need a notification to all threads after consuming data from the queue. 如果队列满了,写线程等待wcond条件变量;读线程在从队列中取出数据之后需要通知所有线程。
It also allows you to unlock the mutex and wait on the condition variable atomically, without the possible intervention of another thread. 它还允许您原子地(atomically)解除互斥的锁定,并等待条件变量,而不会有干涉其他线程的可能。
However, a mutex should accompany each condition variable. 不过,每个条件变量都应该伴有一个互斥。
Condition variables are another feature of particular interest. A condition variable is used to allow a thread to sleep until a condition is true. 条件变量是另一种有趣的变量,条件变量允许在条件不满足时阻塞线程,等条件为真时再唤醒该线程。
If another thread calls pthread_cond_signal() on a condition, then a thread that was waiting on that condition variable is woken up. 如果另一个线程对一个条件变量调用pthreadcondsignal(),那么那个等待这个条件而被阻塞的线程就会被唤醒。
A condition variable enables developers to implement a condition in which a thread executes and then blocked. 条件变量让开发者能够实现一个条件,在这个条件下线程执行然后被阻塞。
Features like process-shared mutexes are also available on Linux, and thus the Solaris code related to IPC mechanisms using pthread mutex locks and condition variable can be used on Linux. 在Linux上还可以利用一些新特性,例如进程共享互斥锁,因此Solaris中使用pthread互斥锁和条件变量的那些有关IPC机制的代码在Linux中都可以使用。
Instead of throwing an exception when the queue is empty, the reader thread now blocks itself on the condition variable. 当队列是空的时候,读线程现在并不抛出异常,而是在条件变量上阻塞自身。
Any financial condition or variable that serves to set wage rates. 能够调节工资高低的财政状况。
In the aspect of theory, the boundary condition with variable storage pipeline volume is proposed. 在理论研究方面,提出了可变管线存储体积的边界条件。
The Study on Reach Condition of Variable Structure Control Systems 变结构控制系统到达条件的研究
Analysis of setting plan and running condition in variable water flow system 空调变流量水系统的设置方案及运行工况分析
Simulation results show that adopting such method can save energy and maintain temperature and humidity in air conditioned zones within comfortable scope under the condition of variable model environment and load parameters. 仿真结果表明,采用此方法,在模型环境、负荷参数变化的情况下,既可以达到节能的要求,又可以使空调区域的温湿度保持在舒适范围内。
To avoid this circumstance, this paper puts forward a method for normalizing Haar function and judging dangerous appearance in combination logic circuit by use of ha coefficient map under the condition of variable number < 6. This method has the characteristics of being simple and direct. 为避免这种现象,给出了Haar函数归一化的一种方法以及在变量数<6时用ha系数图判断组合逻辑电路险象的方法,该方法具有简单、直观的特点。
Reaching Condition of Variable Structure Control for Multivariable Systems 多变量系统变结构控制的一个滑模到达条件
The experiment shows that the HMM wavelet can make the effective diagnosis for various faults of rolling bearings operating under the condition of variable speed and load or unknown speed. 试验证明,小波-HMM可以在变转速变载荷工况下以及未知转速情况下对滚动轴承的各种故障有效地进行诊断。
The result indicates that the disturbance matrix of the complex temperature object is dissatisfied with the matching condition of variable structure control with sliding mode. 转化结果表明,这类复杂温度控制系统的干扰矩阵形式不满足滑模变结构的匹配条件。
Stabilization condition and variable structure control design for singular bilinear systems 广义双线性系统的镇定条件与变结构控制
After this, the influence to structure strength in simple force and boundary is calculated in condition of variable shape and dimension of the opening. 然后分别建立了圆形和长圆形两种开孔形状的开孔板模型,通过改变开孔尺寸的大小,从而计算出简单载荷和边界条件下开孔形状和开孔尺寸对结构强度的影响。
Neural network PID control algorithm with the stator voltage oriented vector control technology can achieve active and reactive power control. It can also guarantee the double-fed asynchronous generator running in the condition of variable speed constant frequency. 电能质量改善主要研究了神经网络PID的控制算法,结合定子电压定向的矢量控制技术实现有功和无功功率的控制,保证双馈电机在变速恒频状态下运转。
Depend on the nature of the variables, it can be divided into three categories: concept variable, environment variable and condition variable. 根据变量的性质不同,论文将其划分为观念变量、环境变量、条件变量三类。
In the period of 1996-2006, joins condition variable FIR, can reduce the speed of divergence in the eastern and western regions, but accelerate the speed of divergence in the central regions. 1996-2006年期间,条件变量FIR的引入,促使东部和西部地区发散速度降低,却加速了中部地区的发散速度。